<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- vue支持绑定自定义事件名 【详细说明-组件化】 -->
        <input type="button" value="触发事件" v-on:aaa="sendCode()">
        <br><br>
        <input type="text" placeholder="手机验证码">
        <!-- <input type="button" 
            v-bind:value=" `发送验证码(${num}S)` " 
            v-bind:disabled=" isSend "
            v-on:click.once="sendCode()"
        > -->
        <!-- v-on:[动态变量] 描述事件名称为仓库的动态变量 -->
        <input type="button" 
            v-bind:value=" `发送验证码(${num}S)` " 
            v-bind:disabled=" isSend "
            v-on:[event]="sendCode()"
        >
    </div>
    <script type="module"> 
        import { createApp } from "../assets/vue3/vue.esm-browser.js";
        createApp({
            data(){
                return {
                    isSend:false,
                    num:20,
                    event:"click"
                }
            },
            methods:{
                sendCode:function(){
                    this.isSend = true;
                    this.event = "";
                    console.log("sendCode")
                    let timer = setInterval(function(){
                        this.num--;
                        if(this.num<=0){
                            clearInterval(timer);
                            this.num = 20;
                            this.isSend = false;
                            this.event = "click";
                        }
                    }, 2000);
                }
            }
        }).mount("#app")
    </script>
</body>
</html>